package com.sprite.email.factory;

import com.sprite.email.strategy.MailStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Service
public class MailStrategyFactory {

    @Autowired Map<String, MailStrategy> mailStrategyMap = new ConcurrentHashMap<>(3);

    public MailStrategy getStrategy(String component) throws Exception{
        MailStrategy strategy = mailStrategyMap.get(component);
        if(strategy == null) {
            throw new RuntimeException("no strategy");
        }
        return strategy;
    }
}
